package com.itzz.spring_zhoneHeng.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyMvcConfig implements WebMvcConfigurer {

    @Value("${path.loadPath}")
    String loadPath;

    @Value("${path.urlPath}")
    String urlPath;

    /*资源访问处理器*/
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //添加访问资源的路径
        registry.addResourceHandler(urlPath+"**")
                //添加资源在本机的位置
                .addResourceLocations("file:"+loadPath);
    }


}
